







Algorithms..::BinarySearch<(Of <T>)> Method (IList<(Of <T>)>, T, IComparer<(Of <T>)>, Int32%) |
See Also |
![]() ![]() |
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Searches a sorted list for an item via binary search. The list must be sorted
by the ordering in the passed instance of IComparer<T>.
Namespace: Wintellect.PowerCollections
Assembly:
PowerCollections (in PowerCollections.dll)
Syntax
C# |
---|
public static int BinarySearch<T>( IList<T> list, T item, IComparer<T> comparer, out int index ) |
Visual Basic (Declaration) |
---|
Public Shared Function BinarySearch(Of T) ( _ list As IList(Of T), _ item As T, _ comparer As IComparer(Of T), _ <OutAttribute> ByRef index As Integer _ ) As Integer |
Visual C++ |
---|
public: generic<typename T> static int BinarySearch ( IList<T>^ list, T item, IComparer<T>^ comparer, [OutAttribute] int% index ) |
Parameters
- list
- IList<(Of <T>)>
The sorted list to search.
- item
- T
The item to search for.
- comparer
- IComparer<(Of <T>)>
The comparer instance used to sort the list. Only the Compare method is used.
- index
- Int32%
Returns the first index at which the item can be found. If the return value is zero, indicating that item was not present in the list, then this returns the index at which item could be inserted to maintain the sorted order of the list.
Return Value
The number of items equal to item that appear in the list.
Type Parameters
- T
See Also
Algorithms Class
Wintellect.PowerCollections Namespace